<%@ page import="entity.User" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Date" %><%--
  Created by IntelliJ IDEA.
  User: 石小俊
  Date: 2024/11/14
  Time: 18:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>JSTL标签库</title>
</head>
<body>
<%
    int age = 20;
    request.setAttribute("age",age);
    User user = new User(1,"admin","111111","13812345678","江苏-南京");
    User user2 = new User(2,"alice","222222","13812345678","江苏-南京");
    User user3 = new User(3,"jack","333333","13812345678","江苏-南京");
    List<User> users = new ArrayList<User>();
    users.add(user);
    users.add(user2);
    users.add(user3);
    request.setAttribute("users",users);
    request.setAttribute("now",new Date());
%>
<c:if test="${age < 5}">婴儿</c:if>
<c:if test="${age < 18}">少年</c:if>
<c:if test="${age < 30}">青年</c:if>
<c:if test="${age < 65}">中年</c:if>
<c:if test="${age >= 65}">老年</c:if>
<hr>
<c:choose>
    <c:when test="${age < 5}">婴儿</c:when>
    <c:when test="${age < 18}">少年</c:when>
    <c:when test="${age < 30}">青年</c:when>
    <c:when test="${age < 65}">中年</c:when>
    <c:otherwise>老年</c:otherwise>
</c:choose>
<hr>
<table border="1">
    <tr>
        <th>编号</th>
        <th>用户名</th>
        <th>密码</th>
    </tr>
    <c:forEach items="${users}" var="user">
        <tr>
            <td>${user.id}</td>
            <td>${user.username}</td>
            <td>${user.password}</td>
        </tr>
    </c:forEach>
</table>
<hr>
当前时间:<fmt:formatDate value="${now}"></fmt:formatDate><br>
当前时间:<fmt:formatDate value="${now}" type="date"></fmt:formatDate><br>
当前时间:<fmt:formatDate value="${now}" type="time"></fmt:formatDate><br>
当前时间:<fmt:formatDate value="${now}" type="both"></fmt:formatDate><br>
当前时间:<fmt:formatDate value="${now}" pattern="yyyy年MM月dd日 HH:mm:ss E"></fmt:formatDate><br>

</body>
</html>
